﻿function mathThing(number) {
    var result = number += number;
    return result;
}

//console.log(mathThing(5));

//IIFE - Immediately Invoked Function Expression
var theFunctionInside = (function (number) {
    return function () {
        return number += number;
    };
})(5);

//var theFunctionInside = mathThing2(5);
//console.log(theFunctionInside());

for (var i = 1; i <= 5; i++) {
    var func = (function (x) {
        return function () {
            console.log(x);
        }
    })(i);
    setTimeout(func, 1000 * i);
}

var createcar2 = function (number) {
    var nick = 'nick';
    return number * 6;
}

var createCar = function () {
    var securityCode = 0;
    var securityModifier = 6;

    var getSecurityCode = function () {
        return securityCode;
    }

    var setSecurityCode = function (number) {
        securityCode = number * securityModifier;
    }

    return {
        getSecurityCode: getSecurityCode,
        setSecurityCode: setSecurityCode
    }
};

var nicksCars = createCar();
var jimsCar = createCar();

